package org.myapp.datastore.model;

import java.util.Date;

import org.myapp.constants.UserAuthority;
import org.myapp.datastore.DataModel;
import org.myapp.datastore.entity.User;

import com.google.appengine.api.datastore.Entity;

public class UserModel extends DataModel {

    private static final long serialVersionUID = -158764634630013103L;

    public UserModel() {
        super(User.ENTITY.getId());
    }

    public UserModel(Entity entity) {
        super(entity);
    }

    public String getUserId() {
        return (String) getProperty(User.COL_USER_ID.getId());
    }

    public void setUserId(String userId) {
        setProperty(User.COL_USER_ID.getId(), userId);
    }

    public String getPassword() {
        return (String) getProperty(User.COL_PASSWORD.getId());
    }

    public void setPassword(String password) {
        setProperty(User.COL_PASSWORD.getId(), password);
    }

    public String getToken() {
    	return (String) getProperty(User.COL_TOKEN.getId());
    }

    public void setToken(String token) {
    	setProperty(User.COL_TOKEN.getId(), token);
    }

    public Date getLastLoginDate() {

        return (Date) getProperty(User.COL_LAST_LOGIN_DATE.getId());
    }

    public void setLastLoginDate(Date lastLoginDate) {
        setProperty(User.COL_LAST_LOGIN_DATE.getId(), lastLoginDate);
    }

    public void setUserAuthority(UserAuthority auth) {
        setProperty(User.COL_USER_AUTHORITY.getId(), auth.getValue());
    }

    public UserAuthority getUserAuthority() {
        return UserAuthority.getObject((String) getProperty(User.COL_USER_AUTHORITY.getId()));
    }
}
